package com.jk.lesson6;

import com.jk.bean.Dish;
import com.jk.bean.DishType;
import com.jk.lesson2.Apple;

import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by Auser on 2016/12/2.
 */
public class Test {
    public static void main(String...args){
        List<String> abc = Arrays.asList("a", "b", "c", "d");
        List<String> d = Arrays.asList("a", "b");
        List<String> e = abc.stream()
                .flatMap(s ->
                        d.stream().filter(s1 -> s.equals(s1))
                                .map(s1 -> s))
                .collect(Collectors.toList());

        System.out.println(e);
//        System.out.println(UUID.randomUUID().toString().toUpperCase());
//        System.out.println();
//        Float a = null;
//        Float b = 2F;
//
//        System.out.println(b.toString());
//        Apple b = null;
//        Apple a = new Apple();
//        a.setWeight(250);
//        a.setColor("red");
//        List<Apple> apples = new ArrayList<>();
//        apples.add(a);
//        Optional<Apple> appleOptional = apples.stream()
//                .filter(apple -> apple.getWeight() > 200).findFirst();
//        if (appleOptional.isPresent())
//            System.out.println(appleOptional.get().getColor());

    }

    public static boolean isEmpty(CharSequence cs) {
        return cs == null || cs.length() == 0;
    }

    public static boolean isBlank(CharSequence cs) {
        int strLen;
        if(cs != null && (strLen = cs.length()) != 0) {
            for(int i = 0; i < strLen; ++i) {
                if(!Character.isWhitespace(cs.charAt(i))) {
                    return false;
                }
            }

            return true;
        } else {
            return true;
        }
    }
}
